{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import jieba\n",
    "from snownlp import SnowNLP # 使用\n",
    "from snownlp import seg  # 分词库\n",
    "from snownlp import sentiment # 情感分词\n",
    "from snownlp import normal #停用词处理\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "分词： ['小明', '不', '诚信']\n",
      "情感评分（0.6以上为积极，0.2一下为负面）： 0.04020866848778892\n"
     ]
    }
   ],
   "source": [
    "s = SnowNLP(u'小明不诚信')\n",
    "print(\"分词：\",s.words)\n",
    "print(\"情感评分（0.6以上为积极，0.2一下为负面）：\",s.sentiments)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "['小明', '不', '诚信']"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cut = jieba.lcut(\"小明不诚信\")\n",
    "cut"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "分词： ['邻居', '家', '的', '小明', '不', '诚信']\n",
      "情感评分（0.6以上为积极，0.2一下为负面）： 0.16586151271662786\n"
     ]
    }
   ],
   "source": [
    "# jieba.add_word(\"邻居家\")\n",
    "s = SnowNLP('邻居家的小明不诚信')\n",
    "print(\"分词：\",s.words)\n",
    "print(\"情感评分（0.6以上为积极，0.2一下为负面）：\",s.sentiments)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}